import logging
from redis import StrictRedis
class Config(object):

    # 加密方法SECRET_KEY
    SECRET_KEY = 'AC+4jiMLGxT1pwu0j9lUsnPu31WjbBRKAASJrkoH4u6KYS281B3UAlRkRDlvrM/Q2+qyICob1cq926B1+lwIeA=='
    # 一 SQLAlchemy
    SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@192.168.1.4:3306/FirstProject'
    #  追踪数据库更改配置
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 二 redis
    RedisHost = '127.0.0.1'
    ResidPort = 6379

    # 四 Session
    # 设置Session储存配置
    SESSION_TYPE = 'redis'
    # 这个redis 是专门存储 session
    SESSION_REDIS =StrictRedis(host = RedisHost, port= ResidPort )
    # session是否加密
    SESSION_USE_SIGNER = True
    # 如果为True 关闭后cookie自动清除  设置以后有一个过期时间
    SESSION_PERMANENT = True
    # 设置session存活时间

    PERMANENT_SESSION_LIFETIME = 86400 * 2
#  开发过程中，有很多配置，怎么区分配置？ 类继承
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

class DevelopmentEnvironment(Config):

    DEBUG = True
    LOG_LEVEL = logging.DEBUG

class ProductonEnvironment(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING
class TestingEnvironment(Config):
    TESTING = True

config ={
    'development': DevelopmentEnvironment,
    'productor': ProductonEnvironment,
    'testing': TestingEnvironment
}